package com.fy.user.Controller;

import com.fy.user.service.impl.UserServiceImpl;
import com.fy.user.vo.SocialUser;
import com.fy.user.vo.UserLoginVo;
import com.fy.user.vo.UserRegisterVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserServiceImpl userService;


    @PostMapping(value = "/register")
    public Boolean register(@RequestBody UserRegisterVo vo) {
        boolean flag= userService.register(vo);
        return flag;
    }


    @PostMapping(value = "/login")
    public String login(@RequestBody UserLoginVo vo) {
        String login = userService.login(vo);
        return login;
    }

    @PostMapping(value = "/oauth2/login")
    public Map<String, String> oauthLogin(@RequestBody SocialUser socialUser) throws Exception {

        Map<String, String> stringStringMap = userService.weiboLogin(socialUser);
        return stringStringMap;
    }
    @PostMapping(value = "/weixin/login")
    public String weixinLogin(@RequestParam("accessTokenInfo") String accessTokenInfo) {

        String login = userService.weixinLogin(accessTokenInfo);
        return login;
    }

}